using Holoville.HOTween;
using Holoville.HOTween.Core;
using UnityEngine;

public class WindowCompleteMission : MonoBehaviour
{
	private MissionBase curMission;

	[SerializeField]
	private UILabel lbGiveMoney;

	[SerializeField]
	private UILabel lbGiveExp;

	[SerializeField]
	private UILabel lbGiveRep;

	[SerializeField]
	[Space(10f)]
	private UIWidget widget;

	[SerializeField]
	private UIWidget top;

	[SerializeField]
	private UIWidget bot;

	[SerializeField]
	private UIWidget reward;

	private Vector3 startTopPos;

	private Vector3 startBotPos;

	private Vector3 startRewardPos;

	public void Awake()
	{
		startTopPos = top.transform.localPosition;
		startBotPos = bot.transform.localPosition;
		startRewardPos = reward.transform.localPosition;
		widget.alpha = 0f;
		top.alpha = 0f;
		bot.alpha = 0f;
		reward.alpha = 0f;
		top.transform.localPosition = startTopPos + Vector3.right * 200f;
		bot.transform.localPosition = startTopPos + Vector3.left * 200f;
		reward.transform.localPosition = startTopPos + Vector3.up * 100f;
	}

	public void ShowWindow(bool val)
	{
		MyMiniTween[] componentsInChildren = GetComponentsInChildren<MyMiniTween>();
		foreach (MyMiniTween myMiniTween in componentsInChildren)
		{
			myMiniTween.Show(val);
		}
		HOTween.Kill(widget);
		HOTween.Kill(top.transform);
		HOTween.Kill(bot.transform);
		HOTween.Kill(reward.transform);
		HOTween.To(widget, 0.2f, new TweenParms().UpdateType(UpdateType.TimeScaleIndependentUpdate).Prop("alpha", val ? 1 : 0));
		HOTween.To(top, 0.2f, new TweenParms().UpdateType(UpdateType.TimeScaleIndependentUpdate).Prop("alpha", val ? 1 : 0));
		HOTween.To(bot, 0.2f, new TweenParms().UpdateType(UpdateType.TimeScaleIndependentUpdate).Prop("alpha", val ? 1 : 0));
		HOTween.To(top.transform, 0.3f, new TweenParms().UpdateType(UpdateType.TimeScaleIndependentUpdate).Prop("localPosition", (!val) ? (startTopPos + Vector3.right * 200f) : startTopPos).OnComplete((TweenDelegate.TweenCallback)delegate
		{
			if (!val)
			{
				HOTween.To(reward.transform, 0.1f, new TweenParms().UpdateType(UpdateType.TimeScaleIndependentUpdate).Prop("localPosition", startTopPos + Vector3.up * 100f));
				HOTween.To(reward, 0.1f, new TweenParms().UpdateType(UpdateType.TimeScaleIndependentUpdate).Prop("alpha", val ? 1 : 0));
				top.transform.localPosition = startTopPos + Vector3.right * 200f;
				top.alpha = 0f;
			}
			else
			{
				HOTween.To(reward.transform, 0.2f, new TweenParms().UpdateType(UpdateType.TimeScaleIndependentUpdate).Prop("localPosition", startRewardPos));
				HOTween.To(reward, 0.1f, new TweenParms().UpdateType(UpdateType.TimeScaleIndependentUpdate).Prop("alpha", val ? 1 : 0));
				HOTween.To(top.transform, 30f, new TweenParms().UpdateType(UpdateType.TimeScaleIndependentUpdate).Prop("localPosition", startTopPos + Vector3.right * 100f));
				Invoke("Hide", 5f);
			}
		}));
		HOTween.To(bot.transform, 0.3f, new TweenParms().UpdateType(UpdateType.TimeScaleIndependentUpdate).Prop("localPosition", (!val) ? (startBotPos + Vector3.left * 200f) : startBotPos).OnComplete((TweenDelegate.TweenCallback)delegate
		{
			if (!val)
			{
				bot.transform.localPosition = startTopPos + Vector3.left * 200f;
				bot.alpha = 0f;
			}
			else
			{
				HOTween.To(bot.transform, 30f, new TweenParms().UpdateType(UpdateType.TimeScaleIndependentUpdate).Prop("localPosition", startBotPos + Vector3.left * 100f));
			}
		}));
	}

	public void Hide()
	{
		ShowWindow(false);
	}

	public void UpdateParametrMission(MissionBase needMis = null)
	{
		curMission = needMis;
		lbGiveMoney.text = curMission.CountAndAddExeptions.ToString();
		lbGiveExp.text = curMission.GiveExp.ToString();
		lbGiveRep.text = curMission.GiveReputation.ToString();
	}
}
